package com.tuling.iface.demo01;

/**
 * @ClassName FunctionalInterfaceExample
 * @Description TODO
 * @Author tant
 * @Date 2024/6/27 16:27
 */
public class FunctionalInterfaceTest {

    public static void main(String[] args) {
        // 创建匿名内部类实现MyFunctionalInterface接口
        MyFunctionalInterface01 myFuncInterface = new MyFunctionalInterface01() {
            @Override
            public int process(int a, int b) {
                return a+b;
            }
        };

        MyFunctionalInterface01 myFuncInterface01 = (a, b) -> a+b;
        MyFunctionalInterface01 myFuncInterface02 = Integer::sum;

        // 直接调用默认方法
        myFuncInterface.printNumber(10);

        // 调用静态方法
        String staticString = MyFunctionalInterface01.getStaticString();
        System.out.println(staticString);

        // 使用接口中定义的process方法
        int result = myFuncInterface.process(5, 15);
        System.out.println(result);
    }


}
